package com.canyou.constants;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

/**
 * 业务公用常量
 *
 * @author cd
 */
public final class CommonConstants {

    private CommonConstants() {
    }

    public static final String DEFAULT_PASSWORD = "000000";

    /**
     * 默认顶级: 父公司, 父部门, 父菜单, 父配置 等等的id为0
     */
    public static final Long DEFAULT_PARENT_ID = 0L;

    /**
     * jwt签名
     */
    public static final String SIGN_KEY = "cysw#cform";

    /**
     * jwt用户id键
     */
    public static final String USER_ID = "user_id";

    /**
     * jwt用户名键
     */
    public static final String USER_NAME = "user_name";

    /**
     * 图片验证码缓存名
     */
    public static final String CACHE_KAPTCHA_NAME_CODE = "__kaptcha_code__";

    /**
     * 系统默认处理的货币类型
     */
    public static final String CURRENCY_UNIT = "CNY";

    /**
     * 默认日期格式
     */
    public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd";

    /**
     * 系统默认编码
     */
    public static final String DEFAULT_ENCODING = StandardCharsets.UTF_8.toString();

    /**
     * 默认content-type的类型
     */
    public static final String DEFAULT_CONTENT_TYPE = "application/json;charset=utf-8";

    /**
     * 文件下载路由路径
     */
    public static final String DOWN_LOAD_PATH = "/media/download/";

    /**
     * access_token的url key
     */
    public static final String ACCESS_TOKEN_CODE = "access_token";

    public static Map<String, String[]> getMimeType() {
        return MIME_TYPE;
    }

    /**
     * 资源类型(1.image,2.excel,3.word,4.pdf,5.zip)
     */
    private static final Map<String, String[]> MIME_TYPE = new HashMap<>();

    static {
        MIME_TYPE.put("application/msword", new String[]{"doc", "3"});
        MIME_TYPE.put("application/vnd.ms-excel", new String[]{"xls", "2"});
        MIME_TYPE.put("application/vnd.openxmlformats-officedocument.wordprocessingml.document", new String[]{"docx", "3"});
        MIME_TYPE.put("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", new String[]{"xlsx", "2"});
        MIME_TYPE.put("application/vnd.ms-powerpoint", new String[]{"ppt", "0"});
        MIME_TYPE.put("application/vnd.openxmlformats-officedocument.presentationml.presentation", new String[]{"pptx", "0"});
        MIME_TYPE.put("application/x-ppt", new String[]{"ppt", "0"});
        MIME_TYPE.put("application/pdf", new String[]{"pdf", "4"});
        MIME_TYPE.put("application/x-pkcs12", new String[]{"pfx", "6"});
        MIME_TYPE.put("image/png", new String[]{"png", "1"});
        MIME_TYPE.put("image/jpg", new String[]{"jpg", "1"});
        MIME_TYPE.put("image/jpeg", new String[]{"jpeg", "1"});
        MIME_TYPE.put("image/gif", new String[]{"gif", "1"});
        MIME_TYPE.put("application/x-png", new String[]{"png", "1"});
        MIME_TYPE.put("text/plain", new String[]{"txt", "0"});
        MIME_TYPE.put("text/xml", new String[]{"bpmn", "0"});
        MIME_TYPE.put("application/zip", new String[]{"zip", "5"});
        MIME_TYPE.put("application/octet-stream", new String[]{"rar", "5"});
    }

}
